package com.zyf.chapter01.principle.SOLID.ISP.iteration.last;

import com.zyf.chapter01.principle.SOLID.ISP.ConfigSource;
import com.zyf.chapter01.principle.SOLID.ISP.ZookeeperConfigSource;

/**
 * @author yifeng
 */
public class Application {
    static ConfigSource configSource = new ZookeeperConfigSource(/*省略参数*/);
    public static final RedisConfig redisConfig = new RedisConfig(configSource);
    public static final KafkaConfig KafkaConfig = new KafkaConfig(configSource);
    public static final MysqlConfig mysqlConfig = new MysqlConfig(configSource);

    public static void main(String[] args) {
        // 热更新
        ScheduledUpdater redisConfigUpdater = new ScheduledUpdater(redisConfig,100, 100);
        redisConfigUpdater.run();
        ScheduledUpdater kafkaConfigUpdater = new ScheduledUpdater(KafkaConfig,100, 100);
        kafkaConfigUpdater.run();
        // 监控
        SimpleHttpServer simpleHttpServer = new SimpleHttpServer("127.0.0.1", 2389);
        simpleHttpServer.addViews("/config", redisConfig);
        simpleHttpServer.addViews("/config", mysqlConfig);
        simpleHttpServer.run();
    }
}
